package com.lzw.mall.admin.controller;


import com.lzw.mall.admin.entity.Menu;
import com.lzw.mall.admin.service.IMenuService;
import com.lzw.mall.common.vo.LayuiTableVO;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lizhenwei
 * @since 2023-03-17
 */
@Controller
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private IMenuService MenuService;

    @GetMapping("/index")
    public String index() {
        return "menu";
    }

    @GetMapping("/list")
    @ResponseBody
    public LayuiTableVO list(){
        return MenuService.doList();
    }

    @PostMapping("/del")
    @ResponseBody
    public void del(Integer id){
        MenuService.doDelete(id);
    }
    @PostMapping("/save")
    @ResponseBody
    public void save(Menu menu){
        MenuService.saveOrUpdate(menu);
    }

    @GetMapping("/{id}")
    @ResponseBody
    public Menu selectById(@PathVariable("id") Integer id){
        return MenuService.getById(id);
    }

}
